package com.example.demo.controller;

import com.example.demo.core.Page;
import com.example.demo.core.Result;
import com.example.demo.entity.AdminUserLog;
import com.example.demo.service.AdminUserLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 管理员操作日志控制器
 *
 * @author 叮当猫的百宝箱
 * @since 1.0
 */
@Tag(name = "管理员操作日志", description = "管理员操作日志")
@RestController
@RequestMapping("/adminUserLog")
@RequiredArgsConstructor
public class AdminUserLogController {

    private final AdminUserLogService adminUserLogService;

    /**
     * 获取管理员操作日志列表
     *
     * @param pageNum  页码
     * @param pageSize 分页条数
     * @return API全局响应对象
     */
    @Operation(summary = "获取管理员操作日志列表")
    @GetMapping
    @PreAuthorize("hasAuthority('/adminUserLog/show')")
    public Result<Page<AdminUserLog>> getAdminUserLogList(
            @RequestParam(defaultValue = "1", required = false) Integer pageNum,
            @RequestParam(defaultValue = "20", required = false) Integer pageSize) {
        Page<AdminUserLog> adminUserLogList = adminUserLogService.getAdminUserLogList(pageNum, pageSize);
        return Result.ok(adminUserLogList);
    }
}
